<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
   
   
   
    <title><fmt:message key="userProfile.title"/></title>
    <content tag="heading"><fmt:message key="userProfile.heading"/></content>
    <meta name="menu" content="UserMenu"/>

	
<table width="100%" height="76" border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td align="left" valign="top" >  
			<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
			  <tr>
				<td height="25" bgcolor="#5F9CD4" class="font01">&nbsp;&nbsp;&nbsp;系统&gt;&gt; 用户权限&gt;&gt;用户信息</td>
			  </tr>
			  <tr>
				<td height="8"></td>
			  </tr>
			</table>

	        <script type='text/javascript' src='/carsite/dwr/interface/deptMgr.js'></script>
			<script type='text/javascript' src='/carsite/dwr/engine.js'> </script>
			<script type='text/javascript' src='/carsite/dwr/util.js'> </script>
			  <script language="javascript">
					  
					     function onBranchSelect() {
					       var  branchId = document.all.branchId.value;
					       if(branchId != ""){
					           deptMgr.getDeptsByBranch(populateDepts, branchId);
					       }else{
					          alert("请首先选择机构.");
					       }
						   
						}
						function populateDepts(data) {
						  DWRUtil.removeAllOptions("deptId");
						  DWRUtil.addOptions("deptId", data);
						 
						}
						
			
              </script>
				 
			  <!---edit begin--->
              <html:form action="saveUser" styleId="userForm" onsubmit="return validateUserForm(this)">
							<html:hidden property="id"/>
							<html:hidden property="version"/>
							<input type="hidden" name="from" value="<c:out value="${param.from}"/>"/>
							<c:if test="${cookieLogin == 'true'}">
							    <html:hidden property="password"/>
							    <html:hidden property="confirmPassword"/>
							</c:if>
							
							<c:if test="${empty userForm.username}">
							    <input type="hidden" name="encryptPass" value="true"/>
							</c:if>


			  <table width="99%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CDCDCD">
				<tr>
				  <td height="25" background="img/m-bt-bg01.gif" bgcolor="#FFFFFF" style="background-repeat:no-repeat;background-position:right">
				  
					  <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
						  <tr>
							<td width="2%" height="24"><img src="img/dian-1.gif" width="6" height="6" /></td>
							<td width="48%" class="btn02">用户编辑 </td>
							<td width="50%" align="right"><span class="text4"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
						  </tr>
					  </table>
			      </td>
				</tr>
				<tr>
				  <td valign="top" bgcolor="#F8F8F8">
						  
						  
						
				
							<table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="ffffff" bordercolordark="#ffffff" bordercolorlight="B9B9B9">
									<tr align="center">
									  <td width="133" align="center"bgcolor="#EFEFEF"> <carsite:label styleClass="desc" key="userForm.username"/></td>
									  <td width="310" height="28" align="left">
									        <html:errors property="username"/>
									        <html:text styleClass="text large" property="username" styleId="username"/>
        							  </td>
									  <td width="156" align="center"bgcolor="#EFEFEF"> <carsite:label styleClass="desc" key="userForm.userNo"/></td>
									  <td width="625" height="28" align="left">
									        <html:errors property="userNo"/>
									        <html:text styleClass="text large" property="userNo" styleId="userNo"/>
									  </td>
									</tr>
		
        
									<tr align="center">
									  <td align="center" bgcolor="#EFEFEF"><carsite:label styleClass="desc" key="userForm.password"/></td>
									  <td height="28" align="left">
									    <html:errors property="password"/>
						                 <html:password styleClass="text medium" property="password" onchange="passwordChanged(this)"    styleId="password" redisplay="true"/>
					                  </td>
									  <td align="center" bgcolor="#EFEFEF"> <carsite:label styleClass="desc" key="userForm.confirmPassword"/></td>
									  <td height="28" align="left">
									      <html:errors property="confirmPassword"/>
                                          <html:password styleClass="text medium" property="confirmPassword" styleId="confirmPassword" redisplay="true"/>
                                     </td>
									</tr>
									
			
        
									<tr align="center">
									  <td align="center" bgcolor="#EFEFEF"><carsite:label styleClass="desc" key="userForm.firstName"/></td>
									  <td height="28" align="left">
									    <html:errors property="firstName"/>
                                        <html:text styleClass="text medium" property="firstName" styleId="firstName" maxlength="50"/>
									  </td>
									  <td align="center" bgcolor="#EFEFEF"><carsite:label styleClass="desc" key="userForm.email"/></td>
									  <td height="28" align="left">
									     <html:errors property="email"/>
                                         <html:text styleClass="text medium" property="email" styleId="email"/>
									  </td>
								  </tr>
								  
								  <tr align="center">
									  <td align="center" bgcolor="#EFEFEF"> <carsite:label styleClass="desc" key="userForm.phoneNumber"/></td>
									  <td height="28" align="left">
									     <html:errors property="phoneNumber"/>
                                         <html:text styleClass="text medium" property="phoneNumber" styleId="phoneNumber"/>
									  </td>
									  <td align="center" bgcolor="#EFEFEF"><carsite:label styleClass="desc" key="userForm.mobileNo"/></td>
									  <td height="28" align="left">
									     <html:errors property="mobileNo"/>
                                         <html:text styleClass="text medium" property="mobileNo" styleId="mobileNo"/>
                                    </td>
								  </tr>
									
									<tr align="center">
									  <td align="center" bgcolor="#EFEFEF"><carsite:label styleClass="desc" key="userForm.address"/></td>
									  <td height="28" align="left">
									     <html:errors property="postalCode"/>
                                         <html:text styleClass="text medium" property="address" styleId="address"/>
									  </td>
									  								 
								  </tr>
	
								  <tr align="center">
									  <td align="center" bgcolor="#EFEFEF"><carsite:label styleClass="desc" key="userForm.branch"/></td>
									  <td height="28" align="left">
									        <html:text property="branchName" styleClass="inputstyle" onclick="javascript:onShow(this,'branchId','branchDiv')"  size="27" maxlength="27"/>
									    	<html:hidden property="branchId"/>
											<jsp:include page="branchDiv.jsp">
												  <jsp:param name="isParent" value="false" />
											</jsp:include>
							
									  </td>
									  <td align="center" bgcolor="#EFEFEF"><fmt:message key="userForm.dept"/></td>
									  <td height="28" align="left">
									         <html:select property="deptId" styleClass="inputstyle" onfocus="javascript:onBranchSelect()">
				                             </html:select>
				                       </td>
								 
								  </tr>
								  <tr align="center">
									  <td align="center" bgcolor="#EFEFEF"><fmt:message key="userProfile.assignRoles"/></td>
									  <td height="28" colspan="3" align="left">
									   
								            <c:forEach var="role" items="${availableRoles}">
								                <html-el:multibox styleClass="checkbox" property="userRoles" styleId="${role.name}">
								                    <c:out value="${role.name}"/>
								                </html-el:multibox>
								                <label class="choice" for="<c:out value="${role.name}"/>">
								                    <c:out value="${role.cnName}"/>
								                  
								                </label>
								            </c:forEach>
								     
									  </td>
									 
								 
								  </tr>
				    </table>
					         <table  width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="ffffff" bordercolorlight="B9B9B9" bordercolordark="#ffffff">
								  <tr bgcolor="#99CCCC" >
									<td width="32%" height="28" align="center"  bgcolor="#EFEFEF">&nbsp; </td>
									<td width="32%" height="28" align="center"  bgcolor="#EFEFEF">
									
									         <html:submit  property="method.save" onclick="bCancel=false">
								                <fmt:message key="button.save"/>
								            </html:submit>
									         
									         <html:submit  property="method.delete" onclick="bCancel=true; return confirmDelete('User')">
								                <fmt:message key="button.delete"/>
								            </html:submit>
								            <html:cancel onclick="bCancel=true">
								                <fmt:message key="button.cancel"/>
								            </html:cancel>
									
									</td> 
									<td width="36%" height="28"   bgcolor="#EFEFEF" >&nbsp;</td>
								  </tr>
							</table>
							
				  </td>
						</tr>
					  </table>
					    <html:hidden property="accountExpired"/>
				        <html:hidden property="accountLocked"/>
				        <html:hidden property="credentialsExpired"/>
			          </html:form>
			          <!---edit end--->
		
	</td>
  </tr>
</table>

  <script language="javascript">
		
					<c:if test="${not empty userForm.username}">
						
						function init() {
						  
						  var  branchId = document.all.branchId.value;
					       if(branchId != ""){
					           deptMgr.getDeptsByBranch(populateDepts, branchId);
					       }
					       
					       setTimeout("setDeptValue()",100);
					     
						}
						
						function setDeptValue() {
						   document.all.deptId.value= <c:out value="${userForm.deptId}"/>;
					    }
					     init();
					</c:if>	
 </script>

<script type="text/javascript">
    Form.focusFirstElement($('userForm'));
    highlightFormElements();

    function passwordChanged(passwordField) {
        var origPassword = "<c:out value="${userForm.password}"/>";
        if (passwordField.value != origPassword) {
            createFormElement("input", "hidden",
                              "encryptPass", "encryptPass",
                              "true", passwordField.form);
        }
    }
</script>

<html:javascript formName="userForm" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript" src="<c:url value="/scripts/validator.jsp"/>"></script>
